#include "TimeTracker.h"

TimeTracker::TimeTracker(){

/* Actions declaration */
	quitAction = new QAction(tr("Exit"),this);
	connect(quitAction,SIGNAL(triggered()), this, SLOT(quit()));


/*Widgets declaration */
	/* Calendar */
	calendar = new QCalendarWidget;
	calendar->setMinimumDate(QDate(1900,1,1));
	calendar->setMaximumDate(QDate(3000,1,1));
	calendar->setGridVisible(true);	
	/* Buttons Definition */
		/* Main Left Buttons */
	addBut = new QPushButton(tr("Add"));
	editBut = new QPushButton(tr("Edit"));
	removeBut = new QPushButton(tr("Remove"));
	graphicsBut = new QPushButton(tr("Graphics"));

	/* Main Left Vertical Layout */
	mainLeftVLayout = new QVBoxLayout;
	/* add elments in this layout */
	mainLeftVLayout->addWidget(calendar);
	mainLeftVLayout->addWidget(addBut);
	mainLeftVLayout->addWidget(editBut);
	mainLeftVLayout->addWidget(removeBut);
	mainLeftVLayout->addWidget(graphicsBut);

	

	QWidget* qw = new QWidget();

/* Main Layout*/
	mainHLayout = new QHBoxLayout(qw);
	/* add a layout in this layout */
	mainHLayout->addLayout(mainLeftVLayout);

/* window configuration */
	setWindowTitle(tr("TimeTracker"));

	
	fileMenu = menuBar()->addMenu(tr("File"));
		fileMenu->addAction(quitAction);
	editMenu = menuBar()->addMenu(tr("Edit"));
	settingsMenu = menuBar()->addMenu(tr("Settings"));
	aboutMenu = menuBar()->addMenu(tr("About"));

	this->setCentralWidget(qw);
}

void TimeTracker::quit(){

	QMessageBox messageBox;
	messageBox.setWindowTitle(tr("TimeTracker"));
	messageBox.setText(tr("Do you really want to quit?"));
	messageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
	messageBox.setDefaultButton(QMessageBox::No);
	if(messageBox.exec() == QMessageBox::Yes)
		qApp->quit();
}
